package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
@RequiredArgsConstructor
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    private final ${entity}Mapper baseMapper;

    /**
     * 分页查询
     */
    @Override
    public IPage<${entity}> queryPageList(Page<${entity}> pageParam,${entity} vo) {
        LambdaQueryWrapper<${entity}> lqw = buildQueryWrapper(vo);
       return baseMapper.selectPage(pageParam,lqw);
    }

    private LambdaQueryWrapper<${entity}> buildQueryWrapper(${entity} vo) {
        LambdaQueryWrapper<${entity}> lqw = Wrappers.lambdaQuery();
        <#list table.fields as field>
            lqw.eq(vo.get${field.capitalName}() != null, ${entity}::get${field.capitalName}, vo.get${field.capitalName}());
        </#list>


        return lqw;
    }
}
</#if>
